package com.tenwives.ashop.kernel;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.function.Function;

/**
 * 优惠券：满减、立减
 */
@AllArgsConstructor
@Data
public class Coupon implements Function<Double, Double> {
    String name;
    double total;
    double offer;

    @Override
    public Double apply(Double totalPrice) {
        return totalPrice >= total ? (totalPrice + offer) : totalPrice;
    }
}
